package cn.lcsjsxy.yxz.day.Abnormal;

//常见异常2
public class Common2 {

    public static void main(String[] args) {

        //索引越界
        String[] names = new String[3];
        names[0] = "1";
        names[1] = " 2";
        names[2] = " 3";

        if ( names.length == 4){
            names[3] = " 4";
        }

        for (int i = 0; i < names.length; i++){
            System.out.println(names[i]);
        }

        //字符串索引越界
        String a = "123";
//        System.out.println(a.charAt(3));
        System.out.println(a.substring(3));
    }

}
